package com.tarena.myreader.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.tarena.myreader.R;
import com.tarena.myreader.entity.Book;

public class MyBookAdapter extends BaseAdapter<Book>{

	public MyBookAdapter(Context context, List<Book> datas) {
		super(context, datas);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if(convertView==null){
			convertView=getInflater().inflate(R.layout.item_book, null);
			holder=new ViewHolder();
			holder.ivPicture=(ImageView) convertView.findViewById(R.id.iv_book_picture);
			holder.tvName=(TextView) convertView.findViewById(R.id.tv_book_name);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		holder.ivPicture.setImageResource(R.drawable.ic_launcher);
		holder.tvName.setText("MyReader");
		return convertView;
	}
	
	private class ViewHolder{
		ImageView ivPicture;
		TextView tvName;
	}
	
}
